package com.mg.admin.controller.admin;

import com.mg.admin.bean.admin.Result;
import com.mg.admin.bean.admin.WxSetVO;
import com.mg.admin.controller.BaseController;
import com.mg.admin.service.admin.WxSetService;
import com.mg.admin.util.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 公众号管理
 * Created by jujunchen on 2017/9/24.
 */
@Controller
@RequestMapping("/admin/wx/")
public class WxSetController extends BaseController {

    @Autowired
    private WxSetService wxSetService;

    /**
     * 公众号配置
     * @param modelMap
     */
    @GetMapping("set")
    public void set(ModelMap modelMap){
        WxSetVO wxSetVO = wxSetService.findOneById();
        modelMap.put("bean",wxSetVO);
    }

    @PostMapping("set/save")
    @ResponseBody
    public Result setSave(WxSetVO wxSetVO){
        wxSetService.updateOneById(wxSetVO);
        return new Result();
    }

    @PostMapping("set/fileUpload")
    @ResponseBody
    public String fileUpload(HttpServletRequest request){
        String path = FileUtils.uploadFile(request,"file");
        return path;
    }

    @PostMapping("set/getQrcodePreview")
    @ResponseBody
    public Result<String> getQrcodePreview(String qrcodeBackImg, String qrcodeLogoImg){
        //先生成二维码
        return  new Result<>();
    }



}
